define(["jquery", "easy-admin"], function ($, ea) {
  var init = {
    table_elem: '#currentTable',
    table_render_id: 'currentTableRenderId',
    index_url: 'crm/clues.pool/index',
    receive_url: 'crm/clues.pool/receive',
  };

  var Controller = {
    index: function () {
      ea.table.render({
        init: init,
        toolbar:['refresh'],
        cols: [
          [
            {type: "checkbox", width: 50},
            {field: "id", width: 60, title: "ID", sort: true, search: false},
            {field: "name", minWidth: 120, title: "姓名", unresize: true},
            {field: "phone", minWidth: 135, title: "手机号", unresize: true},
            {
              field: "campus_id",
              minWidth: 200,
              templet: function (d) {
                if (d.campus == null) {
                  return "暂无";
                } else {
                  return d.campus.name;
                }
              },
              title: "期望校区",
              search: "select",
              selectList: _campusList,
              unresize: true,
            },
            {
              field: "course_id",
              minWidth: 200,
              templet: function (d) {
                if (d.course == null) {
                  return "暂无";
                } else {
                  return d.course.name;
                }
              },
              title: "咨询课程",
              search: "select",
              selectList: _courseList,
              unresize: true,
            },
            {
              field: "remark",
              minWidth: 135,
              title: "备注",
              templet: function (d) {
                if (d.remark == "") {
                  return "暂无";
                } else {
                  return d.remark;
                }
              },
              searchOp: "%*%",
              unresize: true,
            },
            {
              field: "create_user_id",
              minWidth: 135,
              title: "录入人",
              search: "false",
              templet: function (d) {
                return d.create_user.username;
              },
              unresize: true,
            },
            {
              field: "create_time",
              minWidth: 135,
              title: "创建时间",
              search: "range",
              unresize: true,
            },

            {
              field: "update_time",
              minWidth: 135,
              title: "更新时间",
              search: "range",
              unresize: true,
            },
            {
              field: "status",
              minWidth: 135,
              title: "状态",
              selectList: {0: "待处理", 1: "回访中", 2: "已转正"},
              unresize: true,
            },
            {
              title: "操作",
              minWidth: 80,
              width: 160,
              templet: ea.table.tool,
              align: "center",
              fixed: "right",
              operat: ["receive"],
            },
          ],
        ],
      });

      ea.listen();
    },
    add: function () {
      ea.listen();
    },
    edit: function () {
      ea.listen();
    },
  };
  return Controller;
});
